package com.beiming.common.utils;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TokenUtil {
    /**
     * 获取请求的token
     */
    public static Map getRequestToken(HttpServletRequest httpRequest) {

        //从header中获取token
        String auth_token = httpRequest.getHeader("admin_token");
        String buss_token = httpRequest.getHeader("bussiness_token");
        String user_token = httpRequest.getHeader("user_token");
        String token_type = httpRequest.getHeader("token_type");
        Map<String,String> tokenMap=new HashMap<>();
        tokenMap.put("admin_token",auth_token);
        tokenMap.put("bussiness_token",buss_token);
        tokenMap.put("user_token",user_token);
        tokenMap.put("token_type",token_type);
        //如果header中不存在token，则从参数中获取token
//        if (StringUtils.isBlank(token)) {
//            token = httpRequest.getParameter("admin_token");
//        }

        return tokenMap;
    }
}
